package com.core.website.service.impl;

import com.core.website.entity.CoreUnit;
import com.core.website.mapper.UnitMapper;
import com.core.website.service.UnitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service
public class UnitServiceImpl implements UnitService {
    @Autowired
    private UnitMapper unitMapper;

    @Override
    public int add(CoreUnit coreUnit) {
        coreUnit.setId(UUID.randomUUID().toString().toUpperCase().replace("-", ""));
        return unitMapper.add(coreUnit);
    }

    @Override
    public int edit(CoreUnit coreUnit) {
        return unitMapper.edit(coreUnit);
    }

    @Override
    public int delete(List<String> ids) {
        return unitMapper.delete(ids);
    }

    @Override
    public List<CoreUnit> queryAll(CoreUnit coreUnit) {
        List<CoreUnit> result=unitMapper.queryAll(coreUnit);
        return result;
    }

    @Override
    public CoreUnit queryOne(String id) {
        CoreUnit coreUnit=unitMapper.queryById(id);
        return coreUnit;
    }
}
